<?php
namespace app\baseinfo\model;
use \think\Model;

class Agent extends \app\common\model\Base{
	protected $table='xl_agent';
	// protected $visible=['name','description'];

	// protected $createTime='product_date';

	// protected $autoWriteTimestamp='datetime';

  protected $append = ['area_name','type_name'];

  protected function getTypeNameAttr($value,$data) {
    if (isset($data['type_id'])){
      return model('AgentType')->where('id',$data['type_id'])->value('name');
    } else {
      return null;
    }
  }

  protected function getAreaNameAttr($val,$data) {
    if ($data['area_id']) {
      return model('Area')->get($data['area_id'])->full_name;
    } else {
      return null;
    }
  }

}

?>